/**
 * Description: 登录
 *
 * @author      Eden
 * @datetime    2016/11/25 09:30
 * @copyright   Beijing CmsTop Technology Co.,Ltd.
 */

(function () {
    "use strict";

    var api = {
        cancelUrl: "/money/purchaser/cancel"
    };

    sm.controller('admin-money-purchaser-history', ['$scope', '$http', 'Modal', function ($scope, $http, Modal) {

        $scope.cancel = function (id) {
            if (!id) {
                return false
            }

            Modal.alert({
                title: "操作提示",
                content: "您确定要取消该对账单吗？",
                buttons: [{
                    name: "取消"
                }, {
                    name: "确认",
                    event: function () {
                        doCancel(id);
                    }
                }]
            });
        };

        function doCancel(id) {
            $http.get(api.cancelUrl, {
                params: {
                    id: id
                }
            }).success(function (res) {
                if (res.state) {
                    location.href="/money/history/index"
                } else {
                    Modal.error(res.error?res.error:'对账单取消失败');
                }
            });
        }

    }]);

})();

